from fastapi import FastAPI
from pydantic import BaseModel
from fastapi import Form
import uvicorn


class Item(BaseModel):
    name: str
    description: str = None
    price: float
    tax: float = None


app = FastAPI()


@app.put("/items/{item_id}")
async def create_item(item_id: int, item: Item, q: str = None):
    result = {"item_id": item_id, **item.dict()}
    if q:
        result.update({"q": q})
    return result


@app.post("/login/")
async def login(*, username: str = Form(...), password: str = Form(...)):
     return {"username": username}


if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=8000)
